#pragma once

#include <gmPCurve>
#include "ERBS.h"

namespace GMlib
{


	template <typename T>
	class SimulateERBS : public ERBS<T>
	{
	public:
		SimulateERBS( PCurve<T>* inpCurve, int numbOfLocalCurves, int deg) : ERBS( inpCurve, numbOfLocalCurves, deg)
		{
			
		}

	protected:
		void localSimulate(double dt);

	};

	template <typename T>
	void GMlib::SimulateERBS<T>::localSimulate( double dt )
	{
		static double tim = 0;
		tim += dt;
	
		float freq = 1;
		float scale = 1.0f / 10.0f;


		int totCurves = _localCurves.getDim();
		for(int i=0; i < totCurves; i++)
		{
			float ang = freq*tim + i * 6.28f / totCurves;
			//float tx = sinf(ang);
			//float ty = sinf(ang + 1.57f);
			float tx = 0;
			float ty = 0;
			float tz = sinf(ang + 3.14f);
			//_localCurves[i]->translate( -_localCurves[i]->getPos() );
			_localCurves[i]->translate( Vector3D<float>( tx * scale,ty * scale,tz * scale ) );
		}
		


		this->replot(1000);

	}






} // end namespace GMlib